package com.wpx.log.core.handler.field.render;

import java.util.Date;

import org.springframework.stereotype.Component;

import com.wpx.log.core.annotation.OpLogField;
import com.wpx.log.util.Utils;

@Component
public class DateFieldRenderPolicy implements IFieldRenderPolicy {

	@Override
	public Class<?> getType() {
		return Date.class;
	}

	@Override
	public Object render(Object value, OpLogField opLogField) {
		if(value == null) return "";
		Date date = (Date)value;
		String pattern = opLogField != null? opLogField.format() : "YYYY-MM-dd HH:mm:ss";
		return Utils.dateFormat(date, pattern);
	}

	
}
